package com.cgs.query.handler

import java.util.concurrent.Future

const val HELLO_METHOD: String = "hello"

/**
 * 远程调用
 */
interface RemoteHandler {

    /**
     * 启动招呼
     */
    fun hello(appName: String) {
    }

    /**传输*/
    fun transport(request: Request): Response

    /**
     * 异步传输
     */
    fun asyncTransport(request: Request): Future<Response> {
        TODO("没有实现")
    }

    /**
     * 指定路径传输
     */
    fun urlTransport(url: String, request: Request): Response

    /**
     * 指定路径异步传输
     */
    fun asyncUrlTransport(url: String, request: Request): Future<Response> {
        TODO("没有实现")
    }

    /**
     * 远程传输类型
     */
    fun getRemoteType(): String

}

data class Request(
        val requestId: Long,
        /**方法名*/
        val methodName: String,
        /**参数*/
        val args: List<Any?>,
        /***/
        val returnType: Class<*>
)

data class Response(
        val requestId: Long,
        val result: Any?
) {
    var exception: Throwable? = null
}


class RemoteDetails {
    var urls: List<String>? = null
    var type: String = "NONE"
}

class RemoteInfo {

    var projectName: String = ""

    val details: List<RemoteDetails>? = null
}